﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>2.3.AttributeURL重写</title>
    <script type="text/javascript" src="../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../Content/highlighter/styles/shCoreDefault.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>Url重写</h3>
    <p>
        重写目录
    </p>
    <pre class="brush: csharp;">
        //urlPrefix="/App";
        namespace WebSite.App.Controllers
        {
            public class NewsController
            {
				[RewriteDirectory("/News/","/1/")]
				[RewriteDirectory("/Shop/","/2/")]
				[RewriteDirectory("/Contact/","/3/")]
                [GetHtml("~/{cateId}/{page}.html")]
                public void Index(int cateId,int page)
                {
                    Write("Hello!");
                }
            }
        }
        //把/News/1.html重写为/1/1.html
		//把/Shop/1.html重写为/2/1.html
		//把/Contact/1.html重写为/3/1.html
    </pre>
	<p>
        重写页面
    </p>
    <pre class="brush: csharp;">
        //urlPrefix="/App";
        namespace WebSite.App.Controllers
        {
            public class NewsController
            {
				[RewriteDirectory("/News/","/1/")]
				[RewriteDirectory("/Shop/","/2/")]
				[RewriteDirectory("/Contact/","/3/")]
				[RewriteFile("/1/Index.html","/1/1.html")]
				[RewriteFile("/2/Index.html","/2/1.html")]
				[RewriteFile("/3/Index.html","/3/1.html")]
                [GetHtml("~/{cateId}/{page}.html")]
                public void Index(int cateId,int page)
                {
                    Write("Hello!");
                }
            }
        }
        //把/News/1.html重写为/News/Index.html
		//把/Shop/1.html重写为/Shop/Index.html
		//把/Contact/1.html重写为/Contact/Index.html
    </pre>
	<p>
		config.json重写规则与此规则一致，请参考
		<a href="../3.配置/8.URL重写配置.html">URL重写配置</a>
	</p>
</body>
</html>
